package com.quanyan.ic.video.task;

import com.github.ltsopensource.core.domain.Action;
import com.github.ltsopensource.tasktracker.Result;
import com.github.ltsopensource.tasktracker.runner.JobContext;
import com.github.ltsopensource.tasktracker.runner.JobRunner;
import com.quanyan.ic.video.constants.JobConstant;
import com.quanyan.ic.video.task.job.Hik8710_131331StartEventCheckJob;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author dongsheng.lin
 * @date 2017/7/6
 * @time 17:13
 */
@Component
public class VideoJobRunnerDispatcher implements JobRunner {

    private static Logger logger = LoggerFactory.getLogger(VideoJobRunnerDispatcher.class);

    @Autowired
    private Hik8710_131331StartEventCheckJob hik8710_131331StartEventCheckJob;

    @Override
    public Result run(JobContext jobContext) throws Throwable {
        String taskId = jobContext.getJob().getTaskId();
//        logger.info("定时器收到任务：taskId={}", jobContext.getJob().getTaskId());
        if (taskId.startsWith(JobConstant.START_EVENT_TASK_ID)) {
            hik8710_131331StartEventCheckJob.run(jobContext);
        }
        return new Result(Action.EXECUTE_SUCCESS);
    }
}
